home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / etc / bash_completion.d / ooffice.sh < prev    next >
Encoding:
Text File  |  2007-04-10  |  4.6 KB  |  107 lines

  1. # Programmable bash_completion file for the main OpenOffice.org applications
  2. # It is based on /etc/profile.d/complete.bash from SUSE Linux 10.1
  3.  
  4. _def=; _dir=; _file=; _nosp=
  5. if complete -o default _nullcommand &> /dev/null ; then
  6.     _def="-o default"
  7.     _dir="-o dirnames"
  8.     _file="-o filenames"
  9. fi
  10. _minusdd="-d ${_dir}"
  11. _minusdf="-d ${_file}"
  12. if complete -o nospace _nullcommand &> /dev/null ; then
  13.     _nosp="-o nospace"
  14.     _minusdd="${_nosp} ${_dir}"
  15.     _minusdf="${_nosp} ${_dir}"
  16. fi
  17. complete -r _nullcommand &> /dev/null
  18.  
  19. # General OOo expanding shell function
  20. _ooexp_ ()
  21. {
  22.     # bash `complete' is broken because you can not combine
  23.     # -d, -f, and -X pattern without missing directories.
  24.     local c=${COMP_WORDS[COMP_CWORD]}
  25.     local a="${COMP_LINE}"
  26.     local e s g=0 cd dc t=""
  27.     local IFS
  28.  
  29.     shopt -q extglob && g=1
  30.     test $g -eq 0 && shopt -s extglob
  31.     # Don't be fooled by the bash parser if extglob is off by default
  32.     cd='*-?(c)d*'
  33.     dc='*-d?(c)*'
  34.  
  35.     case "${1##*/}" in
  36.     oobase)        e='!*.+(odb|ODB)' ;;
  37.     oofromtemplate)        e='!*.+(stw|STW|dot|DOT|vor|VOR|stc|STC|xlt|XLT|sti|STI|pot|POT|std|STD|stw|STW)' ;;
  38.     oodraw)        e='!*.+(sxd|SXD|std|STD|dxf|DXF|emf|EMF|eps|EPS|met|MET|pct|PCT|sgf|SGF|sgv|SGV|sda|SDA|sdd|SDD|vor|VOR|svm|SVM|wmf|WMF|bmp|BMP|gif|GIF|jpg|JPG|jpeg|JPEG|jfif|JFIF|fif|FIF|jpe|JPE|pcd|PCD|pcx|PCX|pgm|PGM|png|PNG|ppm|PPM|psd|PSD|ras|RAS|tga|TGA|tif|TIF|tiff|TIFF|xbm|XBM|xpm|XPM|odg|ODG|otg|OTG|odc|ODC|odi|ODI|sds|SDS)' ;;
  39.     oocalc)        e='!*.+(sxc|SXC|stc|STC|dif|DIF|dbf|DBF|xls|XLS|xlw|XLW|xlt|XLT|rtf|RTF|sdc|SDC|vor|VOR|slk|SLK|txt|TXT|htm|HTM|html|HTML|wk1|WK1|wks|WKS|123|123|xml|XML|ods|ODS|ots|OTS|csv|CSV)' ;;
  40.     oomath)        e='!*.+(sxm|SXM|smf|SMF|mml|MML|odf|ODF)' ;;
  41.     ooweb)        e='!*.+(htm|HTM|html|HTML|stw|STW|txt|TXT|vor|VOR|oth|OTH)' ;;
  42.     ooffice)        e='!*.+(sxd|SXD|std|STD|dxf|DXF|emf|EMF|eps|EPS|met|MET|pct|PCT|sgf|SGF|sgv|SGV|sda|SDA|sdd|SDD|vor|VOR|svm|SVM|wmf|WMF|bmp|BMP|gif|GIF|jpg|JPG|jpeg|JPEG|jfif|JFIF|fif|FIF|jpe|JPE|pcd|PCD|pcx|PCX|pgm|PGM|png|PNG|ppm|PPM|psd|PSD|ras|RAS|tga|TGA|tif|TIF|tiff|TIFF|xbm|XBM|xpm|XPM|odg|ODG|otg|OTG|odc|ODC|odi|ODI|sds|SDS|doc|DOC|dot|DOT|rtf|RTF|sxw|SXW|stw|STW|sdw|SDW|vor|VOR|txt|TXT|htm?|HTM?|xml|XML|wp|WP|wpd|WPD|odt|ODT|ott|OTT|sxm|SXM|smf|SMF|mml|MML|odf|ODF|sxi|SXI|sti|STI|ppt|PPT|pps|PPS|pot|POT|sxd|SXD|sda|SDA|sdd|SDD|sdp|SDP|vor|VOR|cgm|CGM|odp|ODP|otp|OTP|odb|ODB|sxc|SXC|stc|STC|dif|DIF|dbf|DBF|xls|XLS|xlw|XLW|xlt|XLT|rtf|RTF|sdc|SDC|vor|VOR|slk|SLK|txt|TXT|htm|HTM|html|HTML|wk1|WK1|wks|WKS|123|123|xml|XML|ods|ODS|ots|OTS|csv|CSV|sxg|SXG|xgl|XGL|txt|TXT|odm|ODM|sgl|SGL|stw|STW|dot|DOT|vor|VOR|stc|STC|xlt|XLT|sti|STI|pot|POT|std|STD|stw|STW|htm|HTM|html|HTML|stw|STW|txt|TXT|vor|VOR|oth|OTH)' ;;
  43.     oowriter)        e='!*.+(doc|DOC|dot|DOT|rtf|RTF|sxw|SXW|stw|STW|sdw|SDW|vor|VOR|txt|TXT|htm?|HTM?|xml|XML|wp|WP|wpd|WPD|odt|ODT|ott|OTT)' ;;
  44.     ooimpress)        e='!*.+(sxi|SXI|sti|STI|ppt|PPT|pps|PPS|pot|POT|sxd|SXD|sda|SDA|sdd|SDD|sdp|SDP|vor|VOR|cgm|CGM|odp|ODP|otp|OTP)' ;;
  45.     *)            e='!*'
  46.     esac
  47.  
  48.     case "$(complete -p ${1##*/} 2> /dev/null)" in
  49.     *-d*)    ;;
  50.     *) s="-S/"
  51.     esac
  52.  
  53.     IFS='
  54. '
  55.     case "$c" in
  56.     \$\(*\))       eval COMPREPLY=\(${c}\) ;;
  57.     \$\(*)        COMPREPLY=($(compgen -c -P '$(' -S ')'  -- ${c#??}))    ;;
  58.     \`*\`)       eval COMPREPLY=\(${c}\) ;;
  59.     \`*)        COMPREPLY=($(compgen -c -P '\`' -S '\`' -- ${c#?}))    ;;
  60.     \$\{*\})       eval COMPREPLY=\(${c}\) ;;
  61.     \$\{*)        COMPREPLY=($(compgen -v -P '${' -S '}'  -- ${c#??}))    ;;
  62.     \$*)        COMPREPLY=($(compgen -v -P '$'          -- ${c#?}))    ;;
  63.     \~*/*)        COMPREPLY=($(compgen -f -X "$e"         -- ${c}))    ;;
  64.     \~*)        COMPREPLY=($(compgen -u ${s}         -- ${c}))    ;;
  65.     *@*)        COMPREPLY=($(compgen -A hostname -P '@' -S ':' -- ${c#*@})) ;;
  66.     *[*?[]*)        COMPREPLY=($(compgen -G "${c}"))            ;;
  67.     *[?*+\!@]\(*\)*)
  68.     if test $g -eq 0 ; then
  69.             COMPREPLY=($(compgen -f -X "$e" -- $c))
  70.             test $g -eq 0 && shopt -u extglob
  71.             return
  72.     fi
  73.             COMPREPLY=($(compgen -G "${c}"))            ;;
  74.     *)
  75.     if test "$c" = ".." ; then
  76.             COMPREPLY=($(compgen -d -X "$e" -S / ${_nosp} -- $c))
  77.     else
  78.             for s in $(compgen -f -X "$e" -- $c) ; do
  79.                 if test -d $s ; then
  80.                 COMPREPLY=(${COMPREPLY[@]} $(compgen -f -X "$e" -S / -- $s))
  81.                 elif test -z "$t" ; then
  82.                 COMPREPLY=(${COMPREPLY[@]} $s)
  83.                 else
  84.                 case "$(file -b $s 2> /dev/null)" in
  85.                 $t) COMPREPLY=(${COMPREPLY[@]} $s)        ;;
  86.                 esac
  87.                 fi
  88.             done
  89.     fi                                    ;;
  90.     esac
  91.     test $g -eq 0 && shopt -u extglob
  92. }
  93.  
  94.  
  95. complete -d -X '.[^./]*' -F _ooexp_ ${_file} \
  96.                     oobase \
  97.                     oofromtemplate \
  98.                     oodraw \
  99.                     oocalc \
  100.                     oomath \
  101.                     ooweb \
  102.                     ooffice \
  103.                     oowriter \
  104.                     ooimpress
  105.  
  106. unset _def _dir _file _nosp _minusdd _minusdf
  107.